package com.huawei.appgallery.common.media.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.huawei.appgallery.common.media.api.OriginalMediaBean;
import com.huawei.appgallery.common.media.bean.SelectedMediaInfo;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import o.bli;
import o.bln;
import o.cdv;

public class BaseThumbnailAdapter extends BaseAdapter {
    protected Context context;
    private String currGroupName = "all_medias";
    protected bli iLoadImageListener;
    protected LayoutInflater inflater;
    protected String mediaType = "image";
    protected List<OriginalMediaBean> originalBeanList;
    protected Map<String, List<OriginalMediaBean>> originalImgBeanMap;
    protected long selectFileMaxSize = Long.MAX_VALUE;
    protected boolean selectForHeadImg = false;
    protected int selectMaxSize = 9;
    protected Map<Integer, SelectedMediaInfo> selectedMap = new HashMap();
    private bln thumbnailManager;

    public BaseThumbnailAdapter(Context context) {
        this.context = context;
        this.thumbnailManager = bln.ˊ();
        this.originalBeanList = this.thumbnailManager.ˎ();
        this.inflater = LayoutInflater.from(cdv.ˊ(context));
    }

    public void setSelectForHeadImg(boolean z) {
        this.selectForHeadImg = z;
    }

    public boolean isAllGroup() {
        return "all_medias".equals(this.currGroupName);
    }

    public void insertFirstAblumItem() {
        if (this.selectMaxSize > 1 && isAllGroup() && this.originalBeanList != null && this.originalBeanList.size() > 0) {
            this.originalBeanList.add(0, new OriginalMediaBean());
        }
    }

    public void setSelectMaxSize(int i) {
        if (i > 0) {
            this.selectMaxSize = i;
        }
    }

    public void setSelectFileMaxSize(long j) {
        if (j > 0) {
            this.selectFileMaxSize = j;
        }
    }

    public int getCount() {
        if (this.originalBeanList == null) {
            return 0;
        }
        return this.originalBeanList.size();
    }

    public Object getItem(int i) {
        if (this.originalBeanList == null) {
            return null;
        }
        return this.originalBeanList.get(i);
    }

    public long getItemId(int i) {
        return (long) i;
    }

    public View getView(int i, View view, ViewGroup viewGroup) {
        return null;
    }

    public void setILoadImageListener(bli o_bli) {
        this.iLoadImageListener = o_bli;
    }

    public void initOriginalImgBeanMap() {
        this.originalImgBeanMap = this.thumbnailManager.ˏ();
    }

    public void setSelectedMap(Map<Integer, SelectedMediaInfo> map) {
        this.selectedMap.clear();
        this.selectedMap.putAll(map);
    }

    public Map<Integer, SelectedMediaInfo> getSelectedMediaMap() {
        return this.selectedMap;
    }

    public String getCurrGroupName() {
        return this.currGroupName;
    }

    public void refreshDateSet(String str) {
        if (!TextUtils.isEmpty(str) && !str.equals(this.currGroupName)) {
            this.currGroupName = str;
            if (str.equals("all_medias")) {
                this.originalBeanList = this.thumbnailManager.ˎ();
                insertFirstAblumItem();
            } else {
                this.originalBeanList = (List) this.originalImgBeanMap.get(str);
            }
            notifyDataSetChanged();
        }
    }
}
